package org.grow.present.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.grow.present.domain.Company;
import org.grow.present.service.CompanyService;
import org.grow.present.mapper.CompanyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * @author admin
 * @description 针对表【company】的数据库操作Service实现
 * @createDate 2025-11-04 21:11:21
 */
@Service
public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company>
        implements CompanyService {
    @Autowired
    private CompanyMapper companyMapper;

    @Override
    public Company forceGet(String openId) {
        QueryWrapper<Company> wrapper = new QueryWrapper<>();
        wrapper.eq("com_no",openId);
        Company company = companyMapper.selectOne(wrapper);
        if(company == null){
            Company com = new Company();
            com.setComId(0);
            com.setComNo(openId);
            com.setComStatus("3");
            com.setComTime(LocalDateTime.now());
            com.setComDel("0");
            com.setComName("微信用户");
            com.setComEmail(null);
            com.setComPhone(null);
            com.setComPwd(null);
            companyMapper.insert(com);
            return companyMapper.selectOne(wrapper);
        }else {
            return  company;
        }
    }
}




